from django.db import models


# Create your models here.
class Category(models.Model):
    title = models.CharField(verbose_name="分类", max_length=100)

    def __str__(self):
        return self.title

    class Meta:
        verbose_name = "课程分类"
        verbose_name_plural = "课程分类"


class Tag(models.Model):
    title = models.CharField(verbose_name="标签", max_length=100)
    category = models.ForeignKey(verbose_name="分类",to="Category",on_delete=models.CASCADE,max_length=100)

    def __str__(self):
        return self.title

    class Meta:
        verbose_name = "课程标签"
        verbose_name_plural = "课程标签"
        unique_together = ("title", "category")



class Course(models.Model):
    title = models.CharField(verbose_name="课程名", max_length=100)
    video = models.FileField(verbose_name="课程视频",upload_to="video")
    price = models.CharField(verbose_name="价格",max_length=100,default="￥29.9元")
    category = models.ForeignKey(verbose_name="分类",to="Category",on_delete=models.CASCADE)
    tag = models.ManyToManyField(verbose_name="标签",to="Tag")
    info = models.CharField(verbose_name="简介",max_length=300)
    author = models.CharField(verbose_name="作者",max_length=100)
    collect_num = models.IntegerField(verbose_name="收藏量",default=0)
    video_time = models.CharField(verbose_name="课程时长",max_length=100,default=" 小时 长的随选视频",blank=True,null=True)
    practice_num = models.CharField(verbose_name="练习数量",max_length=100,default=" 个代码练习",blank=True,null=True)
    homework = models.CharField(verbose_name="作业",max_length=100,default="作业",blank=True,null=True)
    text_num = models.CharField(verbose_name="文章数量",max_length=100,default=" 篇文章",blank=True,null=True)
    download_resources = models.CharField(verbose_name="下载资源",max_length=100,default=" 个可下载资源",blank=True,null=True)
    end_certificate = models.CharField(verbose_name="结业证书",max_length=100,default="结业证书",blank=True,null=True)
    update_time = models.DateTimeField(verbose_name="更新时间",auto_now_add=True)
    fire = models.BooleanField(verbose_name="是否热门",default=False)
    def __str__(self):
        return self.title
    class Meta:
        verbose_name = "课程"
        verbose_name_plural = "课程"


















    #
    # exploitation = models.CharField(verbose_name="开发")
    # business = models.CharField(verbose_name="商务")
    # busFinancial_accounting = models.CharField(verbose_name="财务会计")
    # IT_software = models.CharField(verbose_name="IT与软件")
    # efficiency = models.CharField(verbose_name="工作效率")
    # personal_development = models.CharField(verbose_name="个人发展")
    # devise = models.CharField(verbose_name="设计")
    # marketing = models.CharField(verbose_name="市场营销")
    # health_fitness = models.CharField(verbose_name="健康和健身")
    # music = models.CharField(verbose_name="音乐")
